<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j">

    <ui:composition template="./templates/template.xhtml">

        <ui:define name="content">

            <a4j:region>
                <h:form id="membro-form">
                    <div class="content-center">

                        <a4j:commandLink styleClass="add-link" value="novo membro" action="#{AdministrarMembrosMB.novoMembro}" reRender="cadastro-membro-modal-form">
                            <rich:componentControl for="cadastro-membro-modal" operation="show" event="onclick" />
                        </a4j:commandLink>

                        <rich:dataTable id="tabela-membros" value="#{AdministrarMembrosMB.listMembros}" var="membro"
                                        rendered="#{!empty AdministrarMembrosMB.listMembros}" rows="5">
                            <f:facet name="header">
                                <rich:columnGroup>
                                    <rich:column colspan="6">
                                        <h:outputText value="Membros" />
                                    </rich:column>
                                    <rich:column breakBefore="true">
                                        <h:outputText value="Foto" />
                                    </rich:column>
                                    <rich:column>
                                        <h:outputText value="Nome" />
                                    </rich:column>
                                    <rich:column>
                                        <h:outputText value="Cargo" />
                                    </rich:column>
                                    <rich:column>
                                        <h:outputText value="Perfil" />
                                    </rich:column>
                                    <rich:column>
                                        <h:outputText value="Editar" />
                                    </rich:column>
                                    <rich:column>
                                        <h:outputText value="Excluir" />
                                    </rich:column>
                                </rich:columnGroup>
                            </f:facet>

                            <rich:column>
                                <h:graphicImage style="margin:0 auto;" id="foto" url="#{membro.foto}" border="0" alt="foto do membro" title="foto do membro"/>
                            </rich:column>
                            <rich:column>
                                <h:outputText value="#{membro.nome}" />
                            </rich:column>
                            <rich:column>
                                <h:outputText value="#{membro.cargo.nome}" />
                            </rich:column>
                            <rich:column>
                                <h:outputText value="#{membro.perfil.perfil}" />
                            </rich:column>
                            <rich:column>
                                <a4j:commandLink reRender="edit-membro-modal-from">
                                    <h:graphicImage id="editar" url="./img/editar.png" border="0" alt="editar" title="editar"/>
                                    <f:setPropertyActionListener value="#{membro}" target="#{AdministrarMembrosMB.membro}"/>
                                    <f:setPropertyActionListener value="#{membro.cargo.nome}" target="#{AdministrarMembrosMB.nomeCargo}"/>
                                    <f:setPropertyActionListener value="#{membro.perfil.perfil}" target="#{AdministrarMembrosMB.nomePerfil}"/>
                                    <f:setPropertyActionListener value="#{membro.foto}" target="#{AdministrarMembrosMB.nomeFoto}"/>
                                    <rich:componentControl for="edit-membro-modal" operation="show" event="onclick" />
                                </a4j:commandLink>
                            </rich:column>
                            <rich:column>
                                <a4j:commandLink reRender="edit-membro-modal-from">
                                    <h:graphicImage id="excluir" url="./img/excluir.png" border="0" alt="excluir" title="excluir"/>
                                    <f:setPropertyActionListener value="#{membro}" target="#{AdministrarMembrosMB.membro}"/>
                                    <rich:componentControl for="excluir-membro-modal" operation="show" event="onclick" />
                                </a4j:commandLink>
                            </rich:column>
                        </rich:dataTable>
                        <rich:datascroller for="tabela-membros" maxPages="5" renderIfSinglePage="false" />
                    </div>
                    <div class="content-center" style="text-align:center;">
                        <h:outputText value="Não existem membros cadastrados"
                                      rendered="#{empty AdministrarMembrosMB.listMembros}"/>
                    </div>
                </h:form>
            </a4j:region>
            <ui:include src="./compositions/modalcadastromembro.xhtml" />
            <ui:include src="./compositions/modaleditarmembro.xhtml" />
            <ui:include src="./compositions/modalexcluirmembro.xhtml" />

        </ui:define>

    </ui:composition>
</html>
